/**
 * VariableSettingServiceImpl.java
 * @author
 * 作者 屈甲康 
 */
package org.jackysoft.service.impl;

import java.util.Collection;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jackysoft.data.AbstractDataProvider;
import org.jackysoft.entity.OsVariableContext;
import org.jackysoft.mapper.OsVariableContextMapper;
import org.jackysoft.service.OsVariableContextService;
import org.jackysoft.workflow.util.VarSettingZtreeFunction;
import org.jackysoft.ztree.ZTreeNode;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.google.common.collect.Collections2;

@Service
public class OsVariableContextServiceImpl extends
		AbstractDataProvider<OsVariableContext> implements
		OsVariableContextService {
	final static Log logger = LogFactory
			.getLog(OsVariableContextServiceImpl.class);

	
	@Resource
	OsVariableContextMapper mapper;
	public OsVariableContextServiceImpl() {
		super();
	}

		

	@Override
	public Collection<ZTreeNode> ztree(String refname)
			throws DataAccessException {
		Collection<OsVariableContext> beans = this.findAllByRefname(refname);
		return  Collections2.transform(beans,new VarSettingZtreeFunction());
	}



	@Override
	public OsVariableContext findByName(String refname, String name) {
		
		return mapper.findByName(refname, name);
	}



	@Override
	public Collection<OsVariableContext> findAllByRefname(String refname) {
		 
		Collection<OsVariableContext> beans = mapper.findAllByRefname(refname);
		
		return beans;
	}



	@Override
	public void removeByName(String refname, String name) {
		mapper.deleteByName(refname, name);
	}



	@Override
	public void removeByRefname(String refname) {
		mapper.deleteByRefname(refname);
		
	}



	@Override
	public String findValue(String refname, String name) {
		
		return mapper.findValue(refname, name);
	}
	
	

}